subroutine calculateInitialField(vertex2D,nVer2D,nInCat2D,vertex3D,params,nVer3D,&
    nInCat3D,igT,jgT,ggT,ig,jg,ggu,ggl,di,f,l1,v1,v2,v3,v4,v5,ggl2,ggu2,di2,&
    vnRZ,vnXYZ,va,v0,igT3D,jgT3D,ggT3D,l13d,ig3D,jg3D,igEarth,jgEarth,vn2d_dat,&
    vn3d_dat,va_dat,v0_dat,log_txt,layerType,nObjects)
    common /dim2D/nodesCount2D,elemsCount2D,nodesBoundCount2D,nodesTermCount2D,&
    m2D,mTerm2d,nodesNotTermCount2D
    common /dim3D/nodesCount3D,elemsCount3D,nodesBoundCount3D,edgesTermCount3D,&
    edgesNotTermCount3D,edgesCount3D,nodesTermCount3D,m3D,mTerm3d,nodesNotTermCount3D
    common /commonInfo/ eps2d,eps3d,eps3dNS,radiusRED,maxiter,typeTask,nt,nMaterials,calcWK,calcVP
    common /dimEarth/nodesNotTermEarth,mEarth
    integer elemsCount2D,edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,elemsCount3D
    integer typeTask,calcWK,calcVP,vn2d_dat,vn3d_dat,va_dat,v0_dat,log_txt,typeTask_txt
    real*8 eps2d,eps3d,eps3dNS,radiusRED,vertex2D,vertex3D,params,ggT,ggu,ggl,di,v1,v2,v3,v4,v5,ggl2,ggu2,&
    di2,vnRZ,vnXYZ,ggT3D,va,f,v0
    dimension vertex2D(2,nodesCount2D),nVer2D(4,elemsCount2D),nInCat2D(elemsCount2D),&
    vertex3D(3,nodesCount3D),params(2,nMaterials),nVer3D(14,elemsCount3D),nInCat3D(elemsCount3D),&
    igT(nodesTermCount2D+1),jgT(mTerm2d),ggT(mTerm2d),ig(nodesNotTermCount2D+1),jg(m2d),ggu(m3d),&
    ggl(m3d),di(nodesNotTermCount3D),l1(nodesBoundCount2D),v1(nodesNotTermCount3D),&
    v2(nodesNotTermCount3D),v3(nodesNotTermCount3D),v4(nodesNotTermCount3D),v5(nodesNotTermCount3D),&
    ggl2(m3d),ggu2(m3d),di2(nodesNotTermCount3D),vnRZ(nodesCount2D),vnXYZ(nodesCount3D),&
    igT3D(nodesTermCount3D+1),jgT3D(mTerm3d),ggT3D(mTerm3d),l13d(nodesBoundCount3D),va(nodesCount3D),&
    ig3D(nodesNotTermCount3D+1),jg3D(m2d),f(nodesNotTermCount3D),igEarth(nodesNotTermEarth+1),&
    jgEarth(mEarth),v0(nodesCount3D)

    !calculating normal component of V in RZ and recalculating it to XYZ
    call V_n(vertex2D,nVer2D,nInCat2D,params,igT,jgT,ggT,ig,jg,ggu,ggl,di,&
    f,l1,v1,v2,v3,v4,v5,ggl2,ggu2,di2,vnRZ,vertex3D,nVer3D,nInCat3D,vnXYZ,&
    igT3D,jgT3D,ggT3D,'VP',vn2d_dat,vn3d_dat,log_txt)

    !calculating anomal component of V
    if(layerType.eq.nObjects) then
        call clearVectorDouble(va,nodesCount3D)
    else
        call V_a(params,ig3D,jg3D,ggu,ggl,di,f,l13d,v1,v2,v3,v4,v5,ggl2,&
        ggu2,di2,vnXYZ,vertex3D,nVer3D,nInCat3D,igT3D,jgT3D,ggT3D,va,igEarth,&
        jgEarth,'VP',va_dat,log_txt)
    endif

    do i=1,nodesCount3D
        v0(i)=vnXYZ(i)+va(i)
    enddo
    call writeToFileDouble(v0_dat,v0,nodesCount3D)
    close(v0_dat)
end
!*************************************************************************
!*************************************************************************
!*************************************************************************